package QiYi;

import java.util.Scanner;
import java.util.Stack;

/**
 * Description：
 * Author: zhangc
 * Date：2017/9/10 19:15
 */
public class Deeping {

    public static int getDeep(String str) {
        char[] chars = str.toCharArray();
        Stack<Character> stack = new Stack<>();
        int total = 0;
        for (char aChar : chars) {
            if (aChar == '(') {
                stack.push('(');
            } else if (aChar == ')') {
                if (total < stack.size())
                    total = stack.size();
                stack.pop();
            }
        }
        return total;
    }

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        String trim = scanner.nextLine().trim();
        System.out.println(getDeep(trim));
    }
}
